<?php 

$userid = intval($_GET['id']);
$groupid = intval($_GET['groupid']);


if($new['user']->isUser($userid)==false){

	header("HTTP/1.1 404 Not Found");
	header("Status: 404 Not Found");
	$title = '404';
	include pubTemplate("404");
	exit;

}

$strUser = $new['user']->getOneUser($userid);
$arrOrg = aac('user')->findAll('user_org');
$arrGroup = aac('group')->findAll('group','isplace>0');

if($TS_USER['userid'] && $TS_USER['userid'] != $strUser['userid']){
	$groupids = explode(',',$strUser['groupids']);
	foreach($groupids as $v){
		$myGroup = aac('group')->getOneGroup($v);
		if(in_array($TS_USER['userid'],$myGroup['admin'])){
			$leader = 1;
			break;
		}
	}
}


$my = $new['user']->getOneUser($TS_USER['userid']);
if($strUser['follow_uid']>0){
	$followUser= $new['user']->getOneUser($strUser['follow_uid']);
}

$iscard =  aac('system')->find('system_options',array('optionname'=>'iscard','optionvalue'=>1));

$sum_duty = $new['user']->findCount('duty',array('userid'=>$userid,'status'=>1));
$strUser['sum_duty'] = $sum_duty;

//是否关注
if($TS_USER['userid'] != '' && $TS_USER['userid'] != $strUser['userid']){
	$followNum = $db->once_num_rows("select * from ".dbprefix."user_follow where userid='".$TS_USER['userid']."' and userid_follow='$userid'");
	if($followNum > '0'){
		$strUser['isfollow'] = true;
	}else{
		$strUser['isfollow'] = false;
	}
}else{
	$strUser['isfollow'] = false;
}

if($strUser['leadership']){

		switch($strUser['leadership']){
			case 1:
				$leadership='馆长';
				break;
			case 2:
				$leadership='理事';
				break;
			case 3:
				$leadership='馆长、理事';
				break;
		}

}

//他关注的用户
$followUsers = $db->fetch_all_assoc("select userid_follow from ".dbprefix."user_follow where userid='$userid' order by addtime desc limit 12");

if(is_array($followUsers)){
	foreach($followUsers as $item){
		$arrFollowUser[] =  $new['user']->getOneUser($item['userid_follow']);
	}
}



$count_stu = 0;
$strStu = aac('user')->findAll('user_coach',array('coachid'=>$userid));
$count_student = count($strStu);
foreach($strStu as $k=>$item){
	$arr = aac('user')->find('user_info',array('userid'=>$item['userid']));
	if($arr['count_duty']<5){
		$count_stu = $count_stu+1;
	}

}
$count_coach = aac('user')->findCount('user_coach',array('userid'=>$userid));


//是否我的教练
$strCoach = aac('user')->find('user_coach',array('userid'=>$TS_USER['userid'],'coachid'=>$userid));

//是否我的学员
$arrCoach = aac('user')->find('user_coach',array('coachid'=>$TS_USER['userid'],'userid'=>$userid,'status'=>0));
